<form action="index.php?id=organisateur_planning" method="post">
<table style="width: 100%; margin: 10px auto 30px auto;">
    <tr>
        <th class="palette palette-firm">Edition</th>
        <th class="palette palette-firm">Date</th>
        <th class="palette palette-firm">Lieu</th>
        <th class="palette palette-firm" colspan="2">Action</th>
    </tr>
<?php
    while($aData = pg_fetch_array($aTournoiData))
    {
        if (isset($_GET['update']) && $_GET['update'] == $aData['edition'])
        {
            echo '<tr>';
            echo '  <td class="palette palette-clouds" style="text-align: center;"><input type="hidden" value="' . $aData['edition'] . '" name="edition" />' . $aData['edition'] . '</td>';
            echo '  <td class="palette palette-clouds" style="text-align: center;">Du <input type="date" value="' . $aData['datedebut'] . '" name="datedebut" /> au <input type="date" value="' . $aData['datefin'] . '" name="datefin" /></td>';
            echo '  <td class="palette palette-clouds" style="text-align: center;">
                        <select name="lieu">';
            while($aData2 = pg_fetch_array($aLieuxData))
            {
                echo '<option value="' . $aData2['nom'] .'">' . $aData2['adresse_numero'] . ' ' . $aData2['adresse_rue'] . ', ' . $aData2['adresse_ville'] . ' ' . $aData2['adresse_cpostal'] . '</option>';
            }
            echo        '</select>';
            echo '  <td class="palette palette-clouds" style="text-align: center;" colspan="2"><input type="hidden" name="type" value="update" /><input type="submit" value="Modifier" /></td>';
            echo '</tr>';
        }
        else
        {
            echo '<tr>';
            echo '  <td class="palette palette-clouds">' . $aData['edition'] . '</td>';
            echo '  <td class="palette palette-clouds" style="text-align: center;">Du ' . date("d/m/Y", strtotime($aData['datedebut'])) . ' au ' . date("d/m/Y", strtotime($aData['datefin'])) . '</td>';
            echo '  <td class="palette palette-clouds" style="text-align: center;">' . $aData['nom'] . ' (' . $aData['adresse_numero'] . ' ' . $aData['adresse_rue'] . ', ' . $aData['adresse_ville'] . ' ' . $aData['adresse_cpostal'] . ')</td>';
            echo '  <td class="palette palette-clouds" style="text-align: center;"><a href="index.php?id=organisateur_planning&del=' . $aData['edition'] . '">Supprimer</a></td>';
            echo '  <td class="palette palette-clouds" style="text-align: center;"><a href="index.php?id=organisateur_planning&update=' . $aData['edition'] . '">Modifier</a></td>';
            echo '</tr>';
        }
    }
    if (!isset($_GET['update']))
    {
	    echo '<tr>';
	    echo '  <td class="palette palette-clouds" style="text-align: center;"><input type="text" size="3" value="' . $aData['edition'] . '" name="edition" /></td>';
	    echo '  <td class="palette palette-clouds" style="text-align: center;">Du <input type="date" value="' . $aData['datedebut'] . '" name="datedebut" /> au <input type="date" value="' . $aData['datefin'] . '" name="datefin" /></td>';
	    echo '  <td class="palette palette-clouds" style="text-align: center;">
				<select name="lieu">';
	    while($aData2 = pg_fetch_array($aLieuxData))
	    {
		echo '<option value="' . $aData2['nom'] .'">' . $aData2['adresse_numero'] . ' ' . $aData2['adresse_rue'] . ', ' . $aData2['adresse_ville'] . ' ' . $aData2['adresse_cpostal'] . '</option>';
	    }
	    echo        '</select>';
	    echo '  <td class="palette palette-clouds" style="text-align: center;" colspan="2">
                        <input type="hidden" name="type" value="insert" />
                        <input type="submit" value="Ajouter" />
                    </td>';
	    echo '</tr>';
    }
?>
</table>
